window.addEventListener('load',function(){
 
 
 // 轮播图
 var test = new Swiper('.swiper-test',{
 	autoplay: true,
	loop:true,
	// speed: 1000, // 切换的时间间隔
	pagination: { // 分页器
	    el: '.swiper-test .swiper-pagination',
		clickable: true,
	},
	// 前进/后退按钮
	navigation: {
		nextEl: '.swiper-test .swiper-button-next',
		prevEl: '.swiper-test .swiper-button-prev',
	},
	// effect: 'cube',
	on: {// 监听swiper事件
		init: function(swiper){
			// Swiper初始化了
			console.log('当前的slide序号是'+this.activeIndex);//或者swiper.activeIndex，swiper与this都可指代当前swiper实例					  
		}, 
		// 切换完毕
		transitionEnd: function(){
			// swiper属性 realIndex当前的活跃项的索引从0开始
			console.log(this.realIndex);
		},
	}
	})
	
 
 var li = document.querySelectorAll(".list1 li" );
 var contens = document.querySelectorAll(".tab_content .abc");
 for(var i=0;i<=li.length-1;i++){
	 li[i].setAttribute("index",i);
	 li[i].onclick = function(){
		var index =this.getAttribute("index");
      for(var j =0;j<=li.length-1;j++){
		  li[j].classList.remove("active");
		  contens[j].classList.remove("show");
	  }
	  li[index].classList.add("active");
	  contens[index].classList.add("show");
	 }
 }
   var contens_li =document.querySelectorAll(".tab_content div li");
  for(var i=0;i<=contens_li.length-1;i++){
	  contens_li[i].setAttribute("index",i);
	  	 contens_li[i].onclick = function(){
	  		var index2 =this.getAttribute("index");
	       for(var j =0;j<=contens_li.length-1;j++){
	  		  contens_li[j].classList.remove("active");
	  	  }
	  	  contens_li[index2].classList.add("active");
	  	 }
	  }
	  
	 
	// 全选全不选
	var ez = document.querySelector(".taoci_zongjia span").innerText;
	var xq7 = document.querySelector(".xq7");
	console.log(xq7.innerText);
	console.log(ez);
	console.log(typeof ez);
	 ez = Number(ez);
	console.log(typeof ez);
	 var  ckall = document.querySelector(".yiwai .ckall");
	 var  item = document.querySelector(".yiwai .item");
	 var taoci2  = document.querySelector(".taoci2");
     ckall.onclick = function(){
		 item.checked = ckall.checked;
		
		 
	 }
	 item.onclick = function(){
	 	ckall.checked = item.checked;
		
	 }
	 var  cka = document.querySelector(".yiwai .cka");
	 var  ite = document.querySelector(".yiwai .ite");
	 cka.onclick = function(){
	 		 ite.checked = cka.checked;
			
	 }
	 ite.onclick = function(){
	 	cka.checked = ite.checked;
		
	 }
	
	var  c = document.querySelector(".yiwai .c");
	var  i = document.querySelector(".yiwai .i");
	c.onclick = function(){
			 i.checked = c.checked;
	}
	i.onclick = function(){
		c.checked = i.checked;
	}
	var  ck = document.querySelector(".yiwai .ck");
	var  it = document.querySelector(".yiwai .it");
	ck.onclick = function(){
			 it.checked = ck.checked;
			
	}
	it.onclick = function(){
		ck.checked = it.checked;
		
	}
	var  ckal = document.querySelector(".yiwai .ckal");
	var  items = document.querySelector(".yiwai .items");
	ckal.onclick = function(){
			 items.checked = ckal.checked;
			 
	}
	items.onclick = function(){
		ckal.checked = items.checked;
		
	}
	var  ckalll = document.querySelector(".yiwai .ckalll");
	var  itemm = document.querySelector(".yiwai .itemm");
	ckalll.onclick = function(){
			 itemm.checked = ckalll.checked;
			
	}
	itemm.onclick = function(){
		ckalll.checked = itemm.checked;
		// var  div2 = document.createElement("div");
		// div2.innerHTML = "<div class='taoci_jiage'>"
		//                   +"<p>云空间月卡 50G</p>"
		// 				   +"<span>1元</span>"
		// taoci2.appendChild(div2);
		 ez = ez+1;
		  xq7.innerText =ez;
		// if(){
			
		// }
	}
	
	// 单选复选框意外保险
	var li11 = document.querySelector(".yiwai .li1");
	var li22 = document.querySelector(".yiwai .li2");
	var index4 =true;
	li11.onclick = function(){
		if(index4){
			ckall.checked = true;
			item.checked  = true;
			cka.checked = false;
			ite.checked  = false;
			li11.style.border = "1px solid #FF6700";
			li22.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			div2.innerHTML = "<div class='taoci_jiage'>"
			                  +"<p>意外保障服务</p>"
							   +"<span>349元</span>"
			taoci2.appendChild(div2);
			ez = ez+349;
			xq7.innerText =ez;
		}else{
			ckall.checked = false;
			item.checked  = false;
			li11.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			var taoci2jiage = document.querySelectorAll(".taoci2 .taoci_jiage");
			var txt1= div2.innerHTML;
			for(var i=0;i<=taoci2jiage.length-1;i++){
				if(taoci2jiage[i].innerHTML = txt1 ){
					taoci2.removeChild(txt1);
				}
					
				}
				ez = ez-349;
				xq7.innerText =ez;
		}
		index4 = !index4;
	}
	var index5 =true;
	li22.onclick = function(){
		if(index5){
			cka.checked = true;
			ite.checked  = true;
			ckall.checked = false;
			item.checked  = false;
			li22.style.border = "1px solid #FF6700";
			li11.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			div2.innerHTML = "<div class='taoci_jiage'>"
			                  +"<p>碎屏保障服务</p>"
							   +"<span>249元</span>"
			taoci2.appendChild(div2);
			ez = ez+249;
			 xq7.innerText =ez;
		}else{
			cka.checked = false;
			ite.checked  = false;
			li22.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			var taoci2jiage = document.querySelectorAll(".taoci2 .taoci_jiage");
			var txt1= div2.innerHTML;
			for(var i=0;i<=taoci2jiage.length-1;i++){
				if(taoci2jiage[i].innerHTML = txt1 ){
					taoci2.removeChild(txt1);
				}
					
				}
				ez = ez-249;
				xq7.innerText =ez;
		}
		index5 = !index5;
		
	}
	
	// 单选复选框云空间服务
	var li14 = document.querySelector(".yiwai .li4");
	var li15 = document.querySelector(".yiwai .li5");
	var li16 = document.querySelector(".yiwai .li6");
	var index6 =true;
	li14.onclick = function(){
		if(index6){
			ck.checked = true;
			it.checked  = true;
			ckal.checked = false;
			ckalll.checked = false;
			itemm.checked =false;
			items.checked  = false;
			li14.style.border = "1px solid #FF6700";
			li15.style.border = "1px solid #e0e0e0";
			li16.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			div2.innerHTML = "<div class='taoci_jiage'>"
			                  +"<p>云空间年卡200G</p>"
							   +"<span>79元</span>"
			taoci2.appendChild(div2);
			ez=ez+79;
			 xq7.innerText =ez;
		}else{
			ck.checked = false;
			it.checked  = false;
			li14.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			var taoci2jiage = document.querySelectorAll(".taoci2 .taoci_jiage");
			var txt1= div2.innerHTML;
			for(var i=0;i<=taoci2jiage.length-1;i++){
				if(taoci2jiage[i].innerHTML = txt1 ){
					taoci2.removeChild(txt1);
				}
					
				}
				ez = ez-79;
				xq7.innerText =ez;
			
		}
		index6 = !index6;
	}
	var index7 =true;
	li15.onclick = function(){
		if(index7){
			ck.checked = false;
			it.checked  = false;
			ckal.checked = true;
			ckalll.checked = false;
			itemm.checked =false;
			items.checked  = true;
			li14.style.border = "1px solid #e0e0e0";
			li15.style.border = "1px solid #FF6700";
			li16.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			div2.innerHTML = "<div class='taoci_jiage'>"
			                  +"<p>云空间年卡 50G</p>"
							   +"<span>49元</span></div>"
			taoci2.appendChild(div2);
			 ez = ez+49;
			  xq7.innerText =ez;
			
		}else{
			ckal.checked = false;
			items.checked  = false;
			li15.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			var taoci2jiage = document.querySelectorAll(".taoci2 .taoci_jiage");
			var txt1= div2.innerHTML;
			for(var i=0;i<=taoci2jiage.length-1;i++){
				if(taoci2jiage[i].innerHTML = txt1 ){
					taoci2.removeChild(txt1);
				}
					
				}
				ez = ez-49;
				xq7.innerText =ez;
		}
		index7 = !index7;
		
	}
	var index8 =true;
	li16.onclick = function(){
		if(index8){
			ck.checked = false;
			it.checked  = false;
			ckal.checked = false;
			ckalll.checked = true;
			itemm.checked =true;
			items.checked  = false;
			li14.style.border = "1px solid #e0e0e0";
			li15.style.border = "1px solid #e0e0e0";
			li16.style.border = "1px solid #FF6700";
			var  div2 = document.createElement("div");
			div2.innerHTML = "<div class='taoci_jiage  wangba'>"
			                  +"<p>云空间月卡 50G</p>"
							   +"<span>1元</span></div>"
			taoci2.appendChild(div2);
			ez = ez+1;
			xq7.innerText =ez;
			
		}else{
			ckalll.checked = false;
			itemm.checked  = false;
			li16.style.border = "1px solid #e0e0e0";
			var  div2 = document.createElement("div");
			var taoci2jiage = document.querySelectorAll(".taoci2 .taoci_jiage");
			var txt1= div2.innerHTML;
			for(var i=0;i<=taoci2jiage.length-1;i++){
				if(taoci2jiage[i].innerHTML = txt1 ){
					taoci2.removeChild(txt1);
				}
					
				}
				ez = ez-1;
				xq7.innerText =ez;
			}
		index8 = !index8;
		
	}
	

	
})